package com.formula.datastructure.exercise.list;

/**
 * ADT
 * getLength
 * insert(data)
 * find(data)
 * update(idx, data)
 * getByIdx(idx)
 * deleteByIdx(idx)
 * deleteByData(data)
 */
public class LinkList {

    private LinkNode head;
    private LinkNode tail;

    public void insertHead(Integer data) {
        LinkNode node = new LinkNode();
        node.data = data;
        if (head.next != null) {
            node.next = head.next;
        }
        head.next = node;
    }

    public void insertTail(Integer data) {
        LinkNode node = new LinkNode();
        node.data = data;

        if (tail.next != null) {
            tail.next.next = node;
        } else {
            tail.next = node;
        }
    }
}
